﻿using System;
using System.Web.Profile;

namespace N2.BlogEngine
{
	using be = global::BlogEngine.Core;
	
	static class ProfileExtensions
	{
		public static be.AuthorProfile AsBlogEngine(this ProfileBase profile)
		{
			DateTime _dt;
			bool _bool;

			return new be.AuthorProfile {
				Id = profile.UserName,
				DisplayName = (string)profile["DisplayName"],
				FirstName = (string)profile["FirstName"],
				MiddleName = (string)profile["MiddleName"],
				LastName = (string)profile["LastName"],
				CityTown = (string)profile["CityTown"],
				RegionState = (string)profile["RegionState"],
				Country = (string)profile["Country"],
				Birthday = (DateTime?)profile["BirthDay"] ?? default(DateTime),
				AboutMe = (string)profile["AboutMe"],
				PhotoURL = (string)profile["PhotoURL"],
				Company = (string)profile["Company"],
				EmailAddress = (string)profile["EmailAddress"],
				PhoneMain = (string)profile["PhoneMain"],
				PhoneMobile = (string)profile["PhoneMobile"],
				PhoneFax = (string)profile["PhoneFax"],
				IsPrivate = (bool?)profile["IsPrivate"] ?? false,
			};
		}
	}
}
